package cn.online.action;

import java.util.List;

import cn.online.model.Student;
import cn.online.service.StudentService;

import com.opensymphony.xwork2.ActionSupport;

public class StudentAction extends ActionSupport {
	
	private StudentService studentService;
	private Student student;
	private List<Student> studentL;
	private Integer sids[];
	
	
	public void setSids(Integer[] sids) {
		this.sids = sids;
	}
	public Student getStudent() {
		return student;
	}
	public void setStudent(Student student) {
		this.student = student;
	}
	public List<Student> getStudentL() {
		return studentL;
	}
	public void setStudentService(StudentService studentService) {
		this.studentService = studentService;
	}
	public String add(){
		studentService.insert(student);
		return SUCCESS;
	}
	
	public String deleteStudents(){
		if(sids==null)
			return INPUT;
		studentService.deleteStudents(sids);
		return SUCCESS;
	}
	
	public String update(){
		studentService.updateStudent(student);
		return SUCCESS;
	}
	
	public String load(){
		if(sids==null)
			return INPUT;
		student = studentService.findById(sids[0]);
		return SUCCESS;
	}
	
	public String list(){
		studentL=studentService.getStudentList();
		return SUCCESS;
	}
}
